import 'package:flutter/material.dart';
import 'widget/language.dart';
import 'binding/binding.dart';
import 'routers/router.dart'; //引入路由配置文件
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

void main() async {
  await ScreenUtil.ensureScreenSize();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context);

    return GetMaterialApp(
      debugShowCheckedModeBanner: false,
      initialRoute: '/', // 初始化的时候加载的路由
      defaultTransition: Transition.rightToLeft, // 页面默认跳转动画
      getPages: AppPage.routes, // 路由
      initialBinding: AllControllerBinding(), //绑定
      // 多语言化配置
      translations: MyTranslations(),
      locale: Get.deviceLocale, // 设置默认语言环境为设备语言
      fallbackLocale: const Locale('en', 'US'), // 设置备用语言环境
      // 设置主题颜色
      theme: ThemeData(
        brightness: Brightness.light,
        primaryColor: Colors.lightBlue[800],
        textTheme: const TextTheme(
          displayLarge: TextStyle(fontSize: 72, fontWeight: FontWeight.bold),
          bodyMedium: TextStyle(fontSize: 14, fontFamily: 'Hind'),
        ),
      ),
    );
  }
}
